package com.lyy.client;

import com.lyy.config.SpringConfiguration;
import com.lyy.domain.Account;
import com.lyy.service.IAccountService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Arrays;
import java.util.List;

public class Test1 {

    @Test
    public void testAdd(){
        ApplicationContext app=new AnnotationConfigApplicationContext(SpringConfiguration.class);
        IAccountService accountService = app.getBean(IAccountService.class);
        Account account=new Account();
        account.setMoney(200);
        account.setName("黄圆圆");
        accountService.insert(account);
    }

    @Test
    public void testFindAll(){
        ApplicationContext app=new AnnotationConfigApplicationContext(SpringConfiguration.class);
        IAccountService accountService = app.getBean(IAccountService.class);
        List<Account> list = accountService.findAll();
        System.out.println(Arrays.toString(list.toArray()));
    }

    @Test
    public void testFindById(){
        ApplicationContext app=new AnnotationConfigApplicationContext(SpringConfiguration.class);
        IAccountService accountService = app.getBean(IAccountService.class);
        Account account = accountService.findById("8e148ef4e524a41af3ce9e551e60b57d");
        System.out.println(account);
    }

    @Test
    public void testDelete(){
        ApplicationContext app=new AnnotationConfigApplicationContext(SpringConfiguration.class);
        IAccountService accountService = app.getBean(IAccountService.class);
        accountService.delete("f10b74d090381b1c45aea245a58f15e8");
    }
}
